Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript valueOf() Method

let x = 123;
x.valueOf();
(123).valueOf();
(100 + 23).valueOf();
Comment

valueof js

/* ValueOf is a prototype that give the Primitive value of a variable
where typeof will give only it types e.g 
*/

const numObj = new Number(42); // let numObj = 42; will work too
console.log(typeof numObj); // output: "object"

const num = numObj.valueOf();
console.log(num);// output: 42

// it works with any type that have a primitive type

let str = new String("Hello"); // let str = "Hello"; will work too 
console.log(str.valueOf()) // output: "Hello"
Comment

PREVIOUS NEXT
Code Example
Javascript :: remove duplicates in array 
Javascript :: javascript remove first element from array 
Javascript :: javascript slice method 
Javascript :: javascript spread operator 
Javascript :: vuelidate required if another props 
Javascript :: js stringify 
Javascript :: inject js on button click chrome extension 
Javascript :: js setattribute download 
Javascript :: HOW TO ADD INDEXES TO EXISTING COLLECTIONS mongodb 
Javascript :: types for parameter destructuring 
Javascript :: js group by 
Javascript :: ejs formatter vscode 
Javascript :: javascript filter array match includes exact 
Javascript :: jest testing with ResizeObserver 
Javascript :: js group objects in array 
Javascript :: returned value by findOneAndUpdate 
Javascript :: moment.set 
Javascript :: discord.js make channel private 
Javascript :: How to Use the trim() String Method in javascript 
Javascript :: js reverse a number 
Javascript :: import url from json angular 
Javascript :: tailwind dynamic classes 
Javascript :: javascript get object where 
Javascript :: reddit fetch api js 
Javascript :: vuex do not mutate vuex store state outside mutation handlers. nuxt 
Javascript :: select child element javascript 
Javascript :: manually set jquery text box 
Javascript :: mangoose connection 
Javascript :: string contains at least one number 
Javascript :: angularjs format number thousands separator 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =