Boolean(value)
instead3193
3194 if (templateName === 'option' || templateName === 'item') {
3195 value = hash_key(data[self.settings.valueField]);
3196 cache = !!value;3197 }
3198
3199 // pull markup from cache if it exists
Boolean(self.settings.openOnFocus)
instead1731 if (!self.$activeItems.length) {
1732 self.showInput();
1733 self.setActiveItem(null);
1734 self.refreshOptions(!!self.settings.openOnFocus);1735 }
1736
1737 self.refreshState();
String(str)
instead 822 * @returns {string}
823 */
824 var escape_replace = function(str) {
825 return (str + '').replace(/\$/g, '$$$$'); 826 };
827
828 var hook = {};
String(str)
instead 808 * @returns {string}
809 */
810 var escape_html = function(str) {
811 return (str + '') 812 .replace(/&/g, '&')
813 .replace(/</g, '<')
814 .replace(/>/g, '>')
String(value)
instead 798 var hash_key = function(value) {
799 if (typeof value === 'undefined' || value === null) return null;
800 if (typeof value === 'boolean') return value ? '1' : '0';
801 return value + ''; 802 };
803
804 /**
Prefer using explicit casts by calling Number
, Boolean
, or String
over using operators like +
, !!
or "" +
.
This is considered best practice as it improves readability.
const b = !!foo;
// The `+` operator does not change the value of its operand
// unless it's already a number.
let n = +foo;
n = 1 * foo;
const s = "" + foo;
const b = Boolean(foo);
const n = Number(foo);
const s = String(foo);