So I'm using a shorthand javascript if/else statement (I read somewhere they're called Ternary statements?)  this.dragHandle.hasClass('handle-low') ? direction = "left" : direction = "right"  This works great, but what...
ES6 introduced a shorthand notation to initialize objects with functions and properties.    // ES6 shorthand notation const obj1 = {     a(b) {         console.log("ES6: obj1");     } };  // ES5 var obj2 = {     a: function a(b) {         con...
I'm wondering if there's a shorter way to write this:  var x = 1; if(y != undefined) x = y;   I initially tried x = y || 1, but that didn't work. What's the correct way to go about this?...
Just as you can convert the following:  var t; if(foo == "bar") {     t = "a"; } else {     t = "b"; }   into:  t = foo == "bar" ? "a" : "b";   , I was wondering if there is a shorthand / oneline way to...
I have this code in a function, and want to shorten it -  it applies the same style to every item in an array.  document.getElementById(divsArray[0]).style.visibility = 'hidden'; document.getElementById(divsArray[1]).style.visibility = 'h...
In some browsers (namely, Firefox) the getComputedStyle().getPropertyValue() doesn't report anything for shorthand CSS, like border. Is there a non-specific-code way of getting these shorthand CSS values? I've considered making a whitelist of...
I try to avoid repetition in my code as much as possible. I know you can turn this:  variable = variable+2   into this  variable += 2   but how can I avoid repetition here? Surely there is a way...  this.className = this.className.replace("classn...
I am trying to get better at shorthand.  Can someone help clarify the below?      (obj.getValue("title")) ? message += "\ntitle: " + obj.getValue("title") : null;   Is it, if obj has a title then add it to the message otherwis...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.