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
//return obj keys | |
$.extend({ | |
keys: function(obj){ | |
var a = []; | |
$.each(obj, function(k){ a.push(k) }); | |
return a; | |
}, | |
eys: function(obj){ | |
return 'test'; | |
} |
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
//charAt(x) | |
var myString = 'jQuery FTW!!!'; | |
console.log(myString.charAt(7)); | |
//output: F |
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
//concat(v1, v2,..) | |
var message="Sam" | |
var final=message.concat(" is a"," hopeless romantic.") | |
//alerts "Sam is a hopeless romantic." | |
alert(final) |
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
//indexOf(char/substring) | |
var sentence="Hi, my name is Sam!" | |
if (sentence.indexOf("Sam")!=-1) | |
alert("Sam is in there!") |
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
//lastIndexOf(substr, [start]) | |
var myString = 'javascript rox'; | |
console.log(myString.lastIndexOf('r')); | |
//output: 11 |
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
//match(regexp) //select integers only | |
var intRegex = /[0-9 -()+]+$/; | |
var myNumber = '999'; | |
var myInt = myNumber.match(intRegex); | |
console.log(isInt); | |
//output: 999 |
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
//replace(substr, replacetext) | |
var myString = '999 JavaScript Coders'; | |
console.log(myString.replace(/JavaScript/i, "jQuery")); | |
//output: 999 jQuery Coders | |
//replace(regexp, replacetext) | |
var myString = '999 JavaScript Coders'; | |
console.log(myString.replace(new RegExp( "999", "gi" ), "The")); |
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
//search(regexp) | |
var intRegex = /[0-9 -()+]+$/; | |
var myNumber = '999'; | |
var isInt = myNumber.search(intRegex); | |
console.log(isInt); | |
//output: 0 |
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
//slice(start, end) | |
var text="excellent" | |
text.slice(0,4) //returns "exce" | |
text.slice(2,4) //returns "ce" |
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
//split(delimiter) | |
var message="Welcome to jQuery4u" | |
//word[0] contains "We" | |
//word[1] contains "lcome to jQuery4u" | |
var word=message.split("l") |
OlderNewer