javascript Programming Glossary: primitives
How to detect if a variable is an array http://stackoverflow.com/questions/1058427/how-to-detect-if-a-variable-is-an-array typeof obj 'undefined' to typeof obj 'object' to exclude primitives and host objects with types distinct from 'object' alltogether... to object is necessary to work correctly for array like primitives ie strings . Here's the code for robust checks for JS arrays..
Object comparison in JavaScript [duplicate] http://stackoverflow.com/questions/1068834/object-comparison-in-javascript y typeof x 'number' typeof y 'number' return true Compare primitives and functions. Check if both arguments link to the same object...
Javascript: Determine whether an array contains a value http://stackoverflow.com/questions/1181575/javascript-determine-whether-an-array-contains-a-value a long time It's best not to patch the prototype of native primitives in JavaScript. A better way var indexOf function needle if typeof..
What is the angularjs way to databind many inputs? http://stackoverflow.com/questions/12977894/what-is-the-angularjs-way-to-databind-many-inputs your list is an array of objects as opposed to an array of primitives . This works fine even though a new scope is created with ng..
How to “properly” create a custom object in JavaScript? http://stackoverflow.com/questions/1595611/how-to-properly-create-a-custom-object-in-javascript the new Shape wrongness. We now have an acceptable set of primitives to built classes. There are a few refinements and extensions..
How do I get the name of an object's type in JavaScript? http://stackoverflow.com/questions/332422/how-do-i-get-the-name-of-an-objects-type-in-javascript true instanceof Boolean false A wrapper is needed around primitives in order for instanceof to work for example new Number 3 instanceof.. is ironic because the .constructor check works fine for primitives 3..constructor Number true 'abc'.constructor String true true.constructor..
Finding Variable Type in JavaScript http://stackoverflow.com/questions/4456336/finding-variable-type-in-javascript 'number' whatever Be careful though if you define these primitives with their object wrappers which you should never do use literals..
How to Deep clone in javascript http://stackoverflow.com/questions/4459928/how-to-deep-clone-in-javascript but first a code example which clones object literals any primitives arrays and nodes. function clone item if item return item null.. check var types Number String Boolean result normalizing primitives if someone did new String 'aaa' or new Number '444' types.forEach..
How does variable assignment work in JavaScript? http://stackoverflow.com/questions/509579/how-does-variable-assignment-work-in-javascript 'foo' b a a 'bar' alert b I suspect that JavaScript treats primitives such as strings and integers differently to hashes. Hashes return.. differently to hashes. Hashes return a pointer while core primitives return a copy of themselves javascript share improve this..
jQuery function to get all unique elements from an array? http://stackoverflow.com/questions/5381621/jquery-function-to-get-all-unique-elements-from-an-array function for accessing only the unique values specifically primitives like integers in an array Obviously we can construct a loop..
What is the purpose of new Boolean() in Javascript? http://stackoverflow.com/questions/856324/what-is-the-purpose-of-new-boolean-in-javascript foo.baz This is not possible with primitive values as primitives can't hold properties var foo true foo.baz 'quux' alert foo.baz..
What is the explanation for these bizarre JavaScript behaviours mentioned in the 'Wat' talk for CodeMash 2012? http://stackoverflow.com/questions/9032856/what-is-the-explanation-for-these-bizarre-javascript-behaviours-mentioned-in-the operator both the left and right operands are converted to primitives first §11.6.1 . As per §9.1 converting an object in this case.. empty string. Similar to both operands are converted to primitives first. For Object objects §15.2 this is again the result of..
|