Code Monkey home page Code Monkey logo

Comments (11)

ooade avatar ooade commented on July 18, 2024

Here's what babel transpiles it to:
babel

I don't think the argument object itself is deprecated. I know of arguments.callee. Besides, Babel transpiles to arguments too so i'd say it isn't that bad to use.

P.S: I think @jeresig is trying to avoid using es6, so it's best we don't add it. Why? It makes it all easy.
And the arguments.callee he used was just for illustration which was backed by the named function.

from advanced-javascript.

ashinzekene avatar ashinzekene commented on July 18, 2024

Okay. Es6 out. I think the source is old though. Really nice repo.

I wonder why people still prefer constructors to factory functions though

from advanced-javascript.

ooade avatar ooade commented on July 18, 2024

I think it all boils down to the implementation details 😅
Although, it does reduce the number of new keywords. Still, it seem a lil bit Verbose compared to the Constructor Pattern.

from advanced-javascript.

ashinzekene avatar ashinzekene commented on July 18, 2024

while trying out one of your quizzes. I did this

function Ninja(){
  this.name = "Ninja";
}

assert(name === "Ninja", "Ooops!, leaked out")

And you can guess the outcome 😄

Kyle Simpson and Eric Elliot prefer factory functions though, but as you said, it all boils down to implementation details.

from advanced-javascript.

ooade avatar ooade commented on July 18, 2024

It's not mine... Full credits to John Resig...
You should get something like name is not defined
Except you called Ninja which in turn, attaches name to the global context?

from advanced-javascript.

ashinzekene avatar ashinzekene commented on July 18, 2024

This actually

function Ninja(){
  this.name = "Ninja";
}

var ninjaA = Ninja(); // This line does the magic
assert( name === "Ninja", "Is undefined, not an instance of Ninja." );
assert( !ninjaA, "Is undefined, not an instance of Ninja." );

from advanced-javascript.

ooade avatar ooade commented on July 18, 2024

@ashinzekene Yeah, Obviously. By calling it that way, name get attached to the global context. The new keyword changes/prevents that :)

from advanced-javascript.

ashinzekene avatar ashinzekene commented on July 18, 2024

Nice 😀

from advanced-javascript.

ashinzekene avatar ashinzekene commented on July 18, 2024

I just wrapped my head around the fact that the this bonding occurs at the call site which is the global context like you said. Did you read Kyle Simpson's book?

from advanced-javascript.

ooade avatar ooade commented on July 18, 2024

I read it. That's great. Kyle is awesome 🌟

from advanced-javascript.

ashinzekene avatar ashinzekene commented on July 18, 2024

Really awesome. Cool. No wonder you're a boss 😂

from advanced-javascript.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.