This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function isPrototypeOf(prototype, object){ | |
| if (prototype === null || undefined){ | |
| return 'null or undefined'; | |
| } | |
| var objectPrototype = Object.getPrototypeOf(object); | |
| while(objectPrototype){ | |
| if(prototype === objectPrototype){ | |
| return true; | |
| } | |
| objectPrototype = Object.getPrototypeOf(objectPrototype); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Step 1 // Remove the call to util.store from the App.render function below | |
| render: function(){ | |
| var todos = this.getFilteredTodos(); | |
| $('#todo-list').html(this.todoTemplate(todos)); | |
| $('#main').toggle(todos.length > 0); | |
| $('#toggle-all').prop('checked', this.getActiveTodos().length === 0); | |
| this.renderFooter(); | |
| $('#new-todo').focus(); | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| After trying a lot of ways removing code seemed to produce the desired effect. | |
| // The code below was commented out in the main app.js file | |
| // if (!val) { | |
| // this.destroy(e); | |
| // return; | |
| // } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var libs = {}; | |
| var libSys = function(libName, depArr, cb){ | |
| if (libName.length > 1 && depArr.length >= 1){ | |
| var storArr = []; | |
| for(var i = 0; i < depArr.length; i++){ | |
| storArr.push(libs[depArr[i]]); | |
| } | |
| libs[libName] = cb.apply(this, storArr); | |
| } else { | |
| libs[libName] = cb(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Object.equals = function( x, y ) { | |
| if ( x === y ) return true; | |
| // if both x and y are null or undefined and exactly the same | |
| if ( ! ( x instanceof Object ) || ! ( y instanceof Object ) ) return false; | |
| // if they are not strictly equal, they both need to be Objects | |
| if ( x.constructor !== y.constructor ) return false; | |
| // they must have the exact same prototype chain, the closest we can do is | |
| // test there constructor. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function isPrototypeOf(parent, child){ | |
| if (parent === null || undefined){ | |
| return false; | |
| } | |
| if (Object.getPrototypeOf(child) === null || undefined){ | |
| return false; | |
| } | |
| return Object.getPrototypeOf(child) === parent || Object.prototype ? true: false; | |
| } | |
| isPrototypeOf(dog, myDog); // returns true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function runWithDebugger(func, args){ | |
| if(args.length>=1){ | |
| debugger; | |
| return func.call(this, args); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //use a var arr = [[[]]]; //////// also side note: don't forget Object.keys() Object.values() and Object.entries() | |
| function transformData(arr){ | |
| var output = {}; | |
| array.forEach(function(item, index){ | |
| if(!item)return; | |
| if(Array.isArray(item)){ | |
| output[index] = transformData(item); | |
| }else{ | |
| output[index] = item; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function rot13(str) { | |
| return str.split('').map.call(str, function(char) { | |
| x = char.charCodeAt(0); | |
| if (x < 65 || x > 90) { | |
| return String.fromCharCode(x); | |
| } | |
| else if (x < 78) { | |
| return String.fromCharCode(x + 13); | |
| } | |
| return String.fromCharCode(x - 13); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function palindrome(str) { | |
| var len = str.length; | |
| for ( var i = 0; i < Math.floor(len/2); i++ ) { | |
| if (str[i] !== str[len - 1 - i]) { | |
| return false; | |
| } | |
| } | |
| return true; | |
| } |
NewerOlder