Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8835547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:17:04+00:00 2026-06-14T09:17:04+00:00

I am trying to execute that really nice deentityify example in Douglas Crockfords J-TBP

  • 0

I am trying to execute that really nice deentityify example in Douglas Crockfords J-TBP book using jsfiddle

String.method('deentityify', function() {
    // The entity table. It maps entity names to
    // characters.
    var entity = {
        quot: '"',
        lt: '<',
        gt: '>'
    };
    // Return the deentityify method.
    return function() {
        // This is the deentityify method. It calls the string
        // replace method, looking for substrings that start
        // with '&' and end with ';'. If the characters in
        // between are in the entity table, then replace the
        // entity with the character from the table. It uses
        // a regular expression (Chapter 7).
        return this.replace(/&([^&;]+);/g, function(a, b) {
            var r = entity[b];
            return typeof r === 'string' ? r : a;
        });
    };
}());

document.writeln('&lt;&quot;&gt;'.deentityify()); // <">          
  • see http://jsfiddle.net/cspeter8/7Pjzs/2/ – and it does not work! I would expect the results pane to display ‘<“>’ but nothing shows up. Would someone like to solve the mystery?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T09:17:05+00:00Added an answer on June 14, 2026 at 9:17 am

    This code-snippet depends on a bit of sugar, namely the method method, that you have to define beforehand. (It’s described early on in the book.) An online copy and explanation of it are in the “Sugar” section of Crockford’s article “Classical Inheritance in JavaScript”. It looks like this:

    Function.prototype.method = function (name, func) {
        this.prototype[name] = func;
        return this;
    };
    

    A corrected version of your Fiddle, incorporating the above, is at http://jsfiddle.net/W9Ncd/.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am trying to execute the records that have TotalTime null value from the
I'm trying to execute a SELECT statement that includes a column of a static
Here is my MySQL Query that im trying to execute. it keeps failing with
Here's a LINQ statement that I am trying to execute var usersQuery = from
I am trying to execute, from a python3 script, Unix commands that looks like
Below you could see template of SQL script that i'm trying to execute on
Ok, so here is the code that I'm trying to execute. begin transaction; SELECT
I am trying to write a bash or PHP script that will execute a
I've been trying to write a function that makes all links execute a function
I am trying to execute a batch file using the Process class. This code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.