www.YoYoBrain.com - Accelerators for Memory and Learning Questions for Ninja Level Javascript

Category: Default - (94 questions) Javascript: What is catch with using new the behavior varies based on what is put in, Object() constructor versus literal syntax {} literal syntax is consistent Javascript: how to create a constructor var Person = function(name) = {} function that will work withvar me = new Person("Will") Javascript: what does keyword "this" refer an empty object that is created by new and to in constructor syntax:var me = new "this" references it Person("Will");var Person = function(name) { this.name = name;} Javascript: when using new operator to var Person = function(name) - { this.name = create an object what is returned implicitly by name}returns object referenced by "this" creation function if nothing is explicitly variable returned Javascript: drawback to defining functions any time you call new Person() a new when creating objects with new operatorvar function is created in memory Person = function(name) { this.say = function(){}}; Javascript: how to avoid creating new add method to prototype function every time new Person() is called chainPerson.prototype.say = function() {}; with old syntaxvar Person() = function(name) { this.say = function() { }} Javascript: what happens to keyword "this" "this" will point to global object when you leave off new keyword when calling constructorme = Person("will") instead of me = new Person("will") Javascript: side effect in object constructor the link to the prototype is lost, so members if you return another object other than "this" added to it will not be available Javascript: pattern to enforce use of new function Person(name) { if (! (this instanceof operator when creating constructor function Person)) { return new Person(name) }} Javascript: how to find name of function arguments.callee()not allowed in ES5 strict within function mode Javascript: new ECMAScript5 way to detect Array.isArray() if variable is array Javascript: older way to detect if object is object.prototype.toString.call(myVar) === an array "[object Array]" Javascript: how to safely parse JSON JSON.parse() Javascript: how to grab the name of a myFunc.name named functionvar myFunc = function funcName() {}; Javascript: how to create a function that "lazy function definition"var myFunc = does initialization first time then acts function() {// my initializationmyFunc = differently next time function() { //regular code}} Javascript: when using "lazy function the original name is rewritten but the new definition" what happens if function is name will still point to original code. So it will assigned to another variable and run run initialization code every time. Javascript: what is immediate function a function that executes as soon as it is defined(function() {...... }() );or(function() {...} )(); Javascript: what is immediate object uses an object with init() method which is initialization executed immediately after object is created.({ .... init: function() {...}}).init(); Javascript: how to alter what "this" refers to myFunc.apply(context, [params] );"this" will in a function point to context Javascript: calling a function is actually applying a set of arguments ____ to a function Javascript: the process of making a function currying understand and handle partial application is called ____ Javascript: simple way of currying function function add(x,y) { var oldx = x, oldy = y; if add(x,y){...} (typeof oldy === "undefined") { //partial return function(newy) { return oldx + newy; };, } return x + y;} Javascript: use case for currying when you find yourself calling the same function and mostly passing the same parameters, create a curry with redundant parameters Javascript: shortcut to check to see if object var MYAPP = MYAPP || {}; defined or define if missing Javascript: how to create private variables enclose them in a functionvar myobject = in object function () { //private members var name = "can't seee"; return {getname: function() {return name;}}}; Javascript: if you want to use private add to prototypemyObj.prototype = variables in object without creating with (function() {....}()); every new obj() call Javascript: how to turn an object literal into JSON.stringify(object) JSON Javascript: how to throw an error with the argument to throw is an object so it can unique properties have any properties you definethrow {message: "something special, remedy: "special sauce"} Javascript: which can be undefined with implied vars created without var keyword keyword deleteglobal created with var keywordimplied globals created without var keyword Javascript: hoisting behavior when you have scattered var declarations in function , they all act as is the variables are declared at the top of function. Can lead to undefined if you reference before the var declaration in the code Javascript: how should this be for( var i=0, max = myarrays.length, i < max, rewrittenfor(var i=0; i< myarray.length, i++) { i++) { // do something } //do something } Javascript: when using for in to loop how to for (var x in obj) { if (obj.hasOwnProperty(x) { filter for objects own properties (not //do something}} inherited) Javascript: what is wrong with if number begins with "0" it will convert to parseInt("something") octalshould be:parseInt("something", 10); Javascript: how to call a function if all you this["foo"](); have is string with function name Javascript: E4X way to add one tag to element1.appendChild( element2 ); another Javascript: E4X way to remove a child node delete element1.elem2 ( elem2 ) from element1 Javascript: E4X what is returned from XML list object element1.bar when there are more than one bar elements Javascript: E4X way to create filter for return place a conditional in parenthesis after the from . or .. selector operatorelement1.foo.(@attribute=="somethi ng") Javascript: E4X way to declare the default default xml namespace="...." namespace Javascript: E4X way to serialize an entire .toXMLString() XML document Javascript: E4X way to grab tag name from .localName QName object Javascript: E4X way to grab namespace .uri from QName object Javascript: E4X way to insert javascript var a = 2;var b = {a}; variable into E4X XML document Javascript: E4X way to grab bar element element1.barorelement1['bar']; ofvar element1 = ; Javascript: E4X way to grab text parts of .text() XML node Javascript: E4X way to grab comment nodes .comments() in XML node Javascript: E4X way to grab XML node .@ operatorelement1.@bar attribute Javascript: E4X way to grab XML node .@ operatorelement1.@bar attribute Javascript: E4X way to find an element that you can access nodes at any depth using the isn't a direct child of top XML element .. operator or descendent propertyelement1..fido Javascript: E4X way to customize the global XML.prototypeorXMLList.prototype XML object Javascript: E4X way to set XML element to var element = ; variable Javascript: E4X way to set multiline XML to var element1 = ; variable Javascript: E4X way to grab Qualified Name .name() from XML object Javascript: how to call a parent object's (Pet) Pet.call(this, arg1, ... ); constructor within Cat constructor Javascript: how to get one object, Cat, to Cat.prototype = new Pet(); inherit from another, Pet Javascript: what is shorthand for parseInt(x) +x Javascript: SVG scalable vector graphicshigh level XML-based markup language where you draw by creating XML elements with attributes to define image JavaScript: how to override use overrideMimeType("text/xml") XMLHttpRequest and parse response as XML / HTML if server doesn't apply text/xml Content-Type header JavaScript: XMLHttpRequest allows tracking adding an event listener to obj.upload the upload process by ______JavaScript: Gecko XMLHttpRequest property channel to specify a channel used by object when performing a request JavaScript: how to set XMLHttpRequest obj.setRequestHeader(header, value) header JavaScript: how to set / catch timeout on obj.timeout = 500;obj.ontimeout = function() XMLHttpRequest object { }; JavaScript: creates a new function that, fun.bind(thisArg [, arg1, ...]) when called, itself calls this function in the context of provides this value JavaScript: XMLHttpRequest 2 adds support FormData for new ______which provides a way to easily construct sets of key/value pairs represents form fields JavaScript: how to add new key/value to append( key, value ) FormData object JavaScript: how to retrieve a FormData var newFormData = new FormData( object from HTML form someFormElement ) JavaScript: if you receive binary data in var byteArray = new uInt8Array( arrayBuffer ) XMLHttpRequest object, how to convert JavaScript: ____ is a data type that is used ArrayBuffer to represent a generic, fixed-length binary data buffer JavaScript: how to create a 32 byte data var buf = new ArrayBuffer(32); buffer JavaScript: when using ArrayBuffer, you viewsJavaScript typed arrays create _____ of underlying data using ______JavaScript: the ____ type describes a ArrayBufferView - base class particular view on the contents of ArrayBuffer's data JavaScript: low-level interface that is DataView subclass of ArrayBufferView for accessing ArrayBuffer JavaScript: 2 objects for accessing an Float32ArrayFloat64Array ArrayBuffer that containing floating number JavaScript: 6 objects for accessing Int8Array UInt8ArrayInt16Array ArrayBuffer with integers UInt16ArrayInt32Array UInt32Array JavaScript: A ____ object represents a Blob file-like object of immutable, raw data JavaScript: an easy way to construct a Blob BlobBuilder is by using ____ interface JavaScript: what is CORS specification cross origin resource sharing JavaScript: ____ object provides info about File and access to the contents of files JavaScript: _____ object is returned by the FileList files property of the HTML file input element JavaScript: _____ object lets web FileReader application asynchronously read the contents of files stored on user's computer JavaScript: how to create a simple URL window.URL.createObjectURL() string which can be used to reference data stored in DOM File or Blob object JavaScript: how to release reference window.URL.revokeObjectURL() created with window.URL.createObjectURL( ) JavaScript: XMLHttpRequest property to obj.withCredentials = true / false; indicate whether or not cross-site Acess-Control requests should be made using credentials JavaScript: Gecko XMLHttpRequest mozBackgroundRequest property that indicates whether object represents a background service request - prevents security dialogs from being shown JavaScript: Gecko XMLHttpRequest obj.multipart = true; property to indicate response is expected to be a stream of possible multiple XML documents JavaScript: how to send binary data with obj.sendAsBinary( ) XMLHttpRequest object JavaScript: how to retrieve binary data in obj.responseType = "arraybuffer" XMLHttpResponse JavaScript: XMLHttpRequest events for progressloaderrorabort monitoring progress ( not readystatechange ) Javascript: event property that gives the screenX / screenY mouse position relative to the entire computer screen of user Javascript: event property that gives the offsetX, offsetY top/left coordinates of mouse pointer relative to the containing object Javascript: event attribute that returns the clientX / clientY horizontal /vertical coordinate according to the viewable client area Javascript: take a number and turn into a String.fromCharCode() character JavaScript: how to find the window that window.opener( ) created a window with window.open() command Javascript: grab the square root of 1/2 Math.SQRT1_2