Trying to bend by head around Javascript's take on OO...and, like many others, running into confusion about the constructor property. In particular, the significance of the constructor property, as I can't seem to make it have any effect. E...
What are the exact circumstances for which a return statement in Javascript can return a value other than this when a constructor is invoked using the new keyword?  Example:  function Foo () {   return something; }  var foo = new Foo ();   If I'...
I'm trying to create a constructor for a blogging platform and it has many async operations going on inside. These range from grabbing the posts from directories, parsing them, sending them through template engines, etc.  So my question is, wou...
Please help me to understand why the following code works:  <script>     var re = RegExp('\\ba\\b') ;     alert(re.test('a')) ;     alert(re.test('ab')) ; </script>   In the first line there is no new operator....
Learning React from the docs and came across this example:  class Square extends React.Component {   constructor() {     super();     this.state = {       value: null,     };   }   ... }   According to Mozilla, super allows you to use this in the con...
I've:  function Obj1(param) {     this.test1 = param || 1;  }  function Obj2(param, par) {     this.test2 = param;  }   now when I do:  Obj2.prototype = new Obj1(44); var obj = new Obj2(55);  alert(obj.constructor)    I have:  function Obj1(param...
After reading this SO Question, I'm still a little confused as to what Array.apply is actually doing. Consider the following snippet:  new Array(5).map(function(){   return new Array(5); });   I expect this to init an array with 5 undefined entri...
I'm browsing the discussion for a similar topic, but can't find my situation...  Am trying call parent constructors with parameters... can't seem to get it right.  I have a PhysicsBody superclass that takes aNode as its only constructor a...
Is there anyway to detect if a JavaScript object is a regex?  For example, I would like to do something like this:  var t = /^foo(bar)?$/i; alert(typeof t); //I want this to return "regexp"   Is this possible?  Thanks!  EDIT: Thanks for all t...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.