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...
There are shorthand operators for the basic arithmetic operators, such as:  x = x+2; x += 2;   or  y = y*2; y *= 2;   However, I was wondering if there was any such operator that could simply invert the value of a boolean.  For example, assuming z =...
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...
Here's the statement:  var H = dr ? ((C < 0 ? 0 : 1) - C) / dr : 0   dr and C are floats.  I don't know what "dr ?" means because it's just a float and not a true/false value.   I was wondering if someone could translate this t...
I am trying to declare 2 variables to the same value ( false ).  I tend to do this all over the place ( like, in almost every object I prototype )  var $a= {border:false ,frame:false};   or alternately   border=false;frame=false;   Is there better wa...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.