Methods in JavaScript ES6 - IndianTechnoEra
Latest update Android YouTube

Methods in JavaScript ES6



JavaScript methods are actions that can be performed on objects. A JavaScript method is a property containing a function definition.



Here is some example of methods with input and output

var myArrray = new Array("el1", "el2","el3")
console.log(typeof(myArrray))
//object
var arr2 = ["l1","l2","l3"]
console.log(arr2.concat(myArrray))
//[ 'l1', 'l2', 'l3', 'el1', 'el2', 'el3' ]

var ar3 = new Array(2,4,'l',7,8,9)
console.log('Root: \n'+ ar3.map(Math.sqrt))
//Root: 1.4142135623730951,2,NaN,2.6457513110645907,2.8284271247461903,3

var ar4 = 'a,b,1,3,2,1'.split(',');
console.log(ar4.map(Math.sqrt))
//[ NaN, NaN, 1, 1.7320508075688772, 1.4142135623730951, 1 ]

console.log(ar3.join('*'))
//2*4*l*7*8*9

var ar5 = ['a','b','c','d']
ar5[ar5.length] = 'e'
console.log(ar5)
// [ 'a', 'b', 'c', 'd', 'e' ]

إرسال تعليق

Feel free to ask your query...
Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.