Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

make shorter if statements with objects

var name_map = {
        "#first": "First Name",
        "#middle": "Middle Name",
        "#last": "Last Name"
}

if (Object.keys(check_map).every(selector => $(selector).val())) { 
	  // Yes, they all have non-blank values
} else {
	// No, at least one of them has a blank value (or didn't exist at all)
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: nodejs: create model by mongoose package 
Javascript :: moment.js get time from now 
Javascript :: tailwind rn npm install 
Javascript :: obfuscate js string 
Javascript :: Uncaught (in promise): NotReadableError: Could not start video source 
Javascript :: webpack.config.js 
Javascript :: function create array javascript 
Javascript :: how to get 6 months after date object 
Javascript :: useref array 
Javascript :: regex exact match 
Javascript :: javascript rest 
Javascript :: multiple forms formData js 
Javascript :: vue method 
Javascript :: remove duplicates in json in flutter 
Javascript :: search node in tree javascript 
Javascript :: two dimensional array in javascript 
Javascript :: eslint disable line 
Javascript :: moment get month day 
Javascript :: ajax call to load a page on scrolling 
Javascript :: convert json string to byte array java 
Javascript :: javascript array foreach 
Javascript :: shell 
Javascript :: spread and rest javascript 
Javascript :: how to decode jwt token at frontend 
Javascript :: .index of javascript 
Javascript :: iterate object in js 
Javascript :: js slice 
Javascript :: js ismobile detected 
Javascript :: library for react table 
Javascript :: fullcalendar edit event modal react 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =