1.angular.bind (self, FN, args)
Function: Returns a new function that binds this function to the self
Parameters:
Self: The context object for the new function
fn: Functions that need to be bound
Args: Arguments passed to a function
Return value: This new function that points to self
varobj ={name:' xxx ', Print:function(country) {Console.log ( This. Name + ' is from ' +country); }};varSelf ={name:' YYY '};varBINDFN = Angular.bind (self, obj.print, ' China ');//var bindfn = Angular.bind (self, obj.print, [' China ']);Obj.print (' American ');//xxx is from AmericanBINDFN ();//yyy is from China
> Note: Bind will decide to invoke call or apply depending on your parameter type, so args can be either data or an array.
2.angular.copy (source, [destination])
function: Deep copy of Object
Parameters:
Source: Origin Object
Destination: Copied objects
Return value: The copied object
var obj = { ' Zuobaiquan ', +}; var copyobj =//Object {name: "Zuobaiquan", age:20}
3.angular.equals (O1, O2)
// true // true // true // false
4.angular.extend (DST, SRC)
Role: Expansion of objects
Parameters:
DST: An Extended object
SRC: Source Object
Return value: Extended Object
var dst = {name: ' xxx ', Country: ' China '};var src = {name: ' yyy ', age:10};angular.extend (DST, SRC); Console.log (SRC); Object {name: "yyy", Age:10}console.log (DST); Object {name: "yyy", Country: "China", age:10}//note here the name becomes "yyy" at this time
5.angular.foreach (obj, iterator, [context])
Role: Traversal of objects
Parameters:
Obj: Object
Iterator: Iterative functions
Context: Contexts in an iterative function
return value: obj
var obj = {name: ' xxx ', Country: ' China '};angular.foreach (obj, function (value, key) {Console.log (key + ': ' + value);}); /name:xxx//country:chinavar array = [' xxx ', ' yyy '];angular.foreach (array, function (item, index) {console.log (index + '): ' + Item + ' from ' + this.country;}, obj.//0:xxx from china//1:yyy
6.angular.fromjson (String)
- Function: String to JSON object
- Parameters:
String: Strings
- Return value: JSON object
var json = Angular.fromjson (' {' name ': ' xxx ', ' age ': ') '; Console.log (JSON); Object {name: "xxx", age:34}
7.angular.tojson (Json,pretty)
Angular.tojson ({name: ' xxx '});//"{" name ":" XXX "}" Angular.tojson ({name: ' xxx '},true);/"{/" name ":" XXX "//}" Angular.tojson ({name: ' xxx '},10);//"{// " name ":" XXX "//}"
8.angular.identity (value)
- Function: Returns the first argument of this function
- Parameters:
Value: Parameter
- Return value: First parameter
Console.log (angular.identity (' xxx ', ' yyy ')); Xxx
9.angular.isarray (value)
- Function: Determine whether a data is an array
- Parameters:
Value: Data
- Return Value: Boolean
Angular.isarray (3); Falseangular.isarray ([]); Trueangular.isarray ([1, 2, 3]); Trueangular.isarray ({name: ' xxx '}); False
10.angular.isdate (value)
Angular.isdate (' 2012-12-02 '); Falseangular.isdate (New Date ()); True
11.angular.isdefined (value)
angular.isdefined (undefined)//falseangular.isdefined ([]); True
12.angular.isundefined (value)
angular.isundefined (undefined)//trueangular.isundefined ([]); False
13.angular.isfunction (value)
- Function: Determine whether a data is a function
- Parameters:
Value: Data
- Return Value: Boolean
Angular.isfunction (function () {}); Trueangular.isfunction (3); False
14.angular.isnumber (value)
- Function: Determine whether a data is a number type
- Parameters:
Value: Data
- Return Value: Boolean
Angular.isnumber (4); Trueangular.isnumber (' xxx '); Falseangular.isnumber (new number (4)); Falseangular.isnumber (number (4)); True
15.angular.isobject (value)
Angular.isobject (' xxx '); False angular.isobject (null);//Falseangular.isobject ([]);//Trueangular.isobject (function () {});// Falseangular.isobject ({name: ' xxx '}); True
16.angular.isstring (value)
Angular.isstring (4); falseangular.isstring (' xxx '); Trueangular.isstring (new String (' xxx ')); Falseangular.isstring (String (' xxx ')); True
17.angular.lowercase (String)
Function: Lowercase the string uppercase
Parameters:
String: Strings
Return value: The new string after the change
var newstring = angular.lowercase (' Xxyyzz '); Console.log (newstring); Xxyyzz
18.angular.uppercase (String)
function: capitalizes the lowercase letter of a string
Parameters:
String: Strings
Return value: The new string after the change
var newstring = angular.uppercase (' Xxyyzz '); Console.log (newstring); Xxyyzz
19.angular.noop ()
Function: null function
var flag = false; Flag? Console.log (' xxx '): Angular.noop ();
If you think the article is good, please Bo Master drink a cup of tea Oh!!!
Angularjs Learning Notes-tool methods