use
Boolean(byUser === true && !$tabId.is('[nu-data-clicked-by-system]'))
instead.3411
3412 const $tabId = $('#' + tab.id)
3413
3414 byUser = !!(byUser === true && !$tabId.is('[nu-data-clicked-by-system]'))3415
3416 if (byUser) nuSaveScrollPositions()
3417
use
Number(match.j)
instead. 557 password: subbedPassword
558 })
559 matchedDictionary.forEach(match => {
560 const token = password.slice(match.i, +match.j + 1 || 9e9) // only return the matches that contain an actual substitution 561
562 if (token.toLowerCase() !== match.matchedWord) {
563 // subset of mappings in sub that are in use for this match
use
Number(j)
instead. 137 break
138 }
139
140 const token = password.slice(i, +j + 1 || 9e9) 141
142 if (maybeDateNoSeparator.exec(token)) {
143 const candidates = []
use
Number(j)
instead. 100 break
101 }
102
103 const token = password.slice(i, +j + 1 || 9e9) 104 const regexMatch = maybeDateWithSeparator.exec(token)
105
106 if (regexMatch != null) {
use
Number(j)
instead. 704
705 for (let i = 0; i < passwordLength; i += 1) {
706 for (let j = i; j < passwordLength; j += 1) {
707 if (passwordLower.slice(i, +j + 1 || 9e9) in rankedDict) { 708 const word = passwordLower.slice(i, +j + 1 || 9e9)
709 const rank = rankedDict[word]
710 matches.push({
use
Number(j)
instead. 705 for (let i = 0; i < passwordLength; i += 1) {
706 for (let j = i; j < passwordLength; j += 1) {
707 if (passwordLower.slice(i, +j + 1 || 9e9) in rankedDict) {
708 const word = passwordLower.slice(i, +j + 1 || 9e9) 709 const rank = rankedDict[word]
710 matches.push({
711 pattern: 'dictionary',
use
Number(j)
instead. 711 pattern: 'dictionary',
712 i,
713 j,
714 token: password.slice(i, +j + 1 || 9e9), 715 matchedWord: word,
716 rank,
717 dictionaryName,
use
Number(j)
instead.1575 pattern: 'sequence',
1576 i,
1577 j,
1578 token: password.slice(i, +j + 1 || 9e9),1579 sequenceName,
1580 sequenceSpace,
1581 ascending: delta > 0
use
Number(j)
instead.1566 const absoluteDelta = Math.abs(delta)
1567
1568 if (absoluteDelta > 0 && absoluteDelta <= this.MAX_DELTA) {
1569 const token = password.slice(i, +j + 1 || 9e9)1570 const {
1571 sequenceName,
1572 sequenceSpace
use
Number(j)
instead.1179 makeBruteforceMatch (i, j) {
1180 return {
1181 pattern: 'bruteforce',
1182 token: this.password.slice(i, +j + 1 || 9e9),1183 i,
1184 j
1185 }
use
Boolean(entry)
instead.1028 let average = 0
1029 Object.keys(graph).forEach(key => {
1030 const neighbors = graph[key]
1031 average += neighbors.filter(entry => !!entry).length1032 })
1033 average /= Object.entries(graph).length
1034 return average
use
String(curr)
instead.1160 }
1161 }
1162
1163 if (funcs['' + curr]) {1164 recursion = true
1165 } else {
1166 funcs['' + curr] = true
use
String(curr)
instead.1163 if (funcs['' + curr]) {
1164 recursion = true
1165 } else {
1166 funcs['' + curr] = true1167 }
1168
1169 stack.push(item)
use
Number(depth)
instead.1191 */
1192 function computeStackTrace (ex, depth) {
1193 let stack = null
1194 depth = (depth == null ? 0 : +depth)1195
1196 try {
1197 // This must be tried first because Opera 10 *destroys*
use
Number(depth)
instead.1254 * @memberof TraceKit.computeStackTrace
1255 */
1256 function computeStackTraceOfCaller (depth) {
1257 depth = (depth == null ? 0 : +depth) + 1 // "+ 1" because "ofCaller" should drop one frame1258 try {
1259 throw new Error()
1260 } catch (ex) {
use
Number(parts[1])
instead. 981 url: parts[2],
982 func: parts[3],
983 args: [],
984 line: +parts[1], 985 column: null
986 }
987 } else if ((parts = lineRE2.exec(lines[line]))) {
use
Number(parts[1])
instead. 989 url: parts[3],
990 func: parts[4],
991 args: [],
992 line: +parts[1], 993 column: null // TODO: Check to see if inline#1 (+parts[2]) points to the script number or column number.
994 }
995 const relativeLine = (+parts[1]) // relative to the start of the <SCRIPT> block
use
Number(parts[1])
instead. 992 line: +parts[1],
993 column: null // TODO: Check to see if inline#1 (+parts[2]) points to the script number or column number.
994 }
995 const relativeLine = (+parts[1]) // relative to the start of the <SCRIPT> block 996 const script = inlineScriptBlocks[parts[2] - 1]
997 if (script) {
998 let source = getSource(item.url)
use
String(func)
instead. 662 const urls = [window.location.href]
663 const scripts = window.document.getElementsByTagName('script')
664 let body
665 const code = '' + func 666 const codeRE = /^function(?:\s+([\w$]+))?\s*\(([\w\s,]*)\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/
667 const eventRE = /^function on([\w$]+)\s*\(event\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/
668 let re
use
Number(parts[3])
instead. 797 url: !isNative ? parts[2] : null,
798 func: parts[1] || UNKNOWN_FUNCTION,
799 args: isNative ? [parts[2]] : [],
800 line: parts[3] ? +parts[3] : null, 801 column: parts[4] ? +parts[4] : null
802 }
803 } else if (parts = winjs.exec(lines[i])) {
use
Number(parts[4])
instead. 798 func: parts[1] || UNKNOWN_FUNCTION,
799 args: isNative ? [parts[2]] : [],
800 line: parts[3] ? +parts[3] : null,
801 column: parts[4] ? +parts[4] : null 802 }
803 } else if (parts = winjs.exec(lines[i])) {
804 element = {
use
Number(parts[3])
instead. 805 url: parts[2],
806 func: parts[1] || UNKNOWN_FUNCTION,
807 args: [],
808 line: +parts[3], 809 column: parts[4] ? +parts[4] : null
810 }
811 } else if ((parts = gecko.exec(lines[i]))) {
use
Number(parts[4])
instead. 806 func: parts[1] || UNKNOWN_FUNCTION,
807 args: [],
808 line: +parts[3],
809 column: parts[4] ? +parts[4] : null 810 }
811 } else if ((parts = gecko.exec(lines[i]))) {
812 isEval = parts[3] && parts[3].indexOf(' > eval') > -1
use
Number(parts[4])
instead. 826 url: parts[3],
827 func: parts[1] || UNKNOWN_FUNCTION,
828 args: parts[2] ? parts[2].split(',') : [],
829 line: parts[4] ? +parts[4] : null, 830 column: parts[5] ? +parts[5] : null
831 }
832 } else {
use
Number(parts[5])
instead. 827 func: parts[1] || UNKNOWN_FUNCTION,
828 args: parts[2] ? parts[2].split(',') : [],
829 line: parts[4] ? +parts[4] : null,
830 column: parts[5] ? +parts[5] : null 831 }
832 } else {
833 continue
Description
Prefer using explicit casts by calling Number
, Boolean
, or String
over using operators like +
, !!
or "" +
.
This is considered best practice as it improves readability.
Bad Practice
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;
Recommended
const b = Boolean(foo);
const n = Number(foo);
const s = String(foo);