Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #26423

Found anb example in a bok but foreachIn does not exist

From "Tony Johansson" <johansson.andersson@telia.com>
Newsgroups comp.lang.javascript
Subject Found anb example in a bok but foreachIn does not exist
Date 2014-12-31 17:27 +0100
Organization A noiseless patient Spider
Message-ID <m8185d$urk$1@dont-email.me> (permalink)

Show all headers | View raw


Here is a function that I have found in a book called "Eloquent JavaScript" 
but  forEachIn does not exist in JavaScript.
How would I changed it so that it works. At the bottom I have give example 
how I call this dom function

function dom(name, attributes /*, children...*/)
       {
          var node = document.createElement(name);
          if (attributes)
          {
              forEachIn(attributes, function (name, value) {
                  node.setAttribute(name, value);
              });
          }

          for (var i = 2; i < arguments.length; i++)
          {
              var child = arguments[i];
              if (typeof child == "string")
                 child = document.createTextNode(child);
              node.appendChild(child);
          }

          return node;
      }

   document.body.appendChild(
         dom("p", null, "A paragraph with a ",
            dom("A", {href: "http://ericsson.se"}, "link"),
              "inside of it."));

//tony 

Back to comp.lang.javascript | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Found anb example in a bok but foreachIn does not exist "Tony Johansson" <johansson.andersson@telia.com> - 2014-12-31 17:27 +0100
  Re: Found anb example in a bok but foreachIn does not exist "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-12-31 19:43 +0100
    Re: Found anb example in a bok but foreachIn does not exist Scott Sauyet <scott.sauyet@gmail.com> - 2015-01-01 22:23 -0800
      Re: Found anb example in a bok but foreachIn does not exist "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-01-02 09:28 +0100
        Re: Found anb example in a bok but foreachIn does not exist "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2015-01-02 07:14 -0800
          Re: Found anb example in a bok but foreachIn does not exist "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-01-03 00:19 +0100
        Re: Found anb example in a bok but foreachIn does not exist Scott Sauyet <scott.sauyet@gmail.com> - 2015-01-02 08:12 -0800
          Re: Found anb example in a bok but foreachIn does not exist "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-01-02 17:52 +0100
          Re: Found anb example in a bok but foreachIn does not exist "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-01-03 00:04 +0100
      Re: Found anb example in a bok but foreachIn does not exist "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2015-01-02 07:06 -0800
  Re: Found anb example in a bok but foreachIn does not exist "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-12-31 19:56 +0100

csiph-web