javascript : Array.contains(Object)
javascript : Array.contains(Object)
Target:
Applicable with Array Data Type.
Description :
Traverse in array and check whether it contains passed Value/Object by checking equality.
Note: If array contains the passed object/value then return true else false.
Syntax:
[].contains(val)
return true or false depending on whether the array contains passed value.
Usase:
- [1,2,3,4,5].contains(1)
It return true - [1,2,3,4,5].contains('1')
It return false - ['1',"2",[3,4,5]].contains('1')
It return true - ['1',"2",[3,4,5]].contains('2')
It return true - ['1',"2",[3,4,5]].contains('3')
It return false - ['1',"2",[3,4,5]].contains([3,4,5])
It return true - var arr=[{pName:"keyboard",price:550},{pName:"mouse",price:350},{pName:"ram",price:3500}];
arr.contains({pName:"mouse",price:350});
It return true - var arr=[{pName:"keyboard",price:550},{pName:"mouse",price:350},{pName:"ram",price:3500}];
arr.contains({price:350, pName:"mouse"});
It return true - var arr=[{pName:"keyboard",price:550},{pName:"mouse",price:350},{pName:"ram",price:3500}];
arr.contains({pName:"mouse",price:355});
It return false
Download MYJS.js
MyJs is a collection of java script extension methods that enhances the JavaScript objects, class object, DOM element, domElementsCollections, Date, String, Number and other data type.
Include in you project landing page (master page) and it will extends your DOM and JavaScript Objects.
Comments
Post a Comment