Expected '===' and instead saw '=='
953 const n = nuSERVERRESPONSE.number_formats
954
955 for (let i = 0; i < n.length; i++) {
956 if (n[i][0] == f) {957 return JSON.parse(n[i][1])
958 }
959 }
Expected '===' and instead saw '=='
940 spl.unshift('')
941 }
942
943 if (o.decimal.length == 1) {944 o.places = spl[1].split(o.decimal)[1].length
945 }
946 }
Expected '===' and instead saw '=='
935 o.places = 0
936 o.format = f
937
938 if (spl.length == 1) {939 o.sign = ''
940 spl.unshift('')
941 }
Expected '===' and instead saw '=='
924function nuNumberFormat (f) {
925 const o = { type: '' }
926
927 if (f[0] == 'N') { // -- number928 const spl = f.substr(2).split(' ') // -- array [sign, number]
929 const n = spl[spl.length - 1] // -- number format
930
Expected '===' and instead saw '=='
901
902 if (l == 'h') { d.h = v[i] }
903 if (l == 'n') { d.n = v[i] }
904 if (l == 's') { d.s = v[i] }905 }
906
907 var o = new Date(d.y, Number(d.m) - 1, d.d, Number(d.h), Number(d.n), Number(d.s), 0)
Expected '===' and instead saw '=='
900 }
901
902 if (l == 'h') { d.h = v[i] }
903 if (l == 'n') { d.n = v[i] }904 if (l == 's') { d.s = v[i] }
905 }
906
Expected '===' and instead saw '=='
899 if (d.y.length == 2) d.y = '20' + d.y
900 }
901
902 if (l == 'h') { d.h = v[i] }903 if (l == 'n') { d.n = v[i] }
904 if (l == 's') { d.s = v[i] }
905 }
Expected '===' and instead saw '=='
896 }
897 if (l == 'y') {
898 d.y = v[i]
899 if (d.y.length == 2) d.y = '20' + d.y900 }
901
902 if (l == 'h') { d.h = v[i] }
Expected '===' and instead saw '=='
894 if (fmt == 'dd') {
895 d.d = v[i]
896 }
897 if (l == 'y') {898 d.y = v[i]
899 if (d.y.length == 2) d.y = '20' + d.y
900 }
Expected '===' and instead saw '=='
891 d.m = FMT[nuTranslateToEnglish(v[i])].mm // -- javascript month
892 }
893
894 if (fmt == 'dd') {895 d.d = v[i]
896 }
897 if (l == 'y') {
Expected '===' and instead saw '=='
887 const fmt = String(f[i])
888 const l = fmt[0]
889
890 if (l == 'm' && FMT[nuTranslateToEnglish(v[i])] !== undefined) {891 d.m = FMT[nuTranslateToEnglish(v[i])].mm // -- javascript month
892 }
893
Expected '!==' and instead saw '!='
860 }
861
862 const FMT = this.setFormats()
863 const hasTime = f.indexOf('hh') != -1 || f.indexOf('nn') != -1 || f.indexOf('ss') != -1 // -- looking for the time864
865 v = String(v)
866 .nuReplaceAll(':', ' ')
Expected '!==' and instead saw '!='
860 }
861
862 const FMT = this.setFormats()
863 const hasTime = f.indexOf('hh') != -1 || f.indexOf('nn') != -1 || f.indexOf('ss') != -1 // -- looking for the time864
865 v = String(v)
866 .nuReplaceAll(':', ' ')
Expected '!==' and instead saw '!='
860 }
861
862 const FMT = this.setFormats()
863 const hasTime = f.indexOf('hh') != -1 || f.indexOf('nn') != -1 || f.indexOf('ss') != -1 // -- looking for the time864
865 v = String(v)
866 .nuReplaceAll(':', ' ')
Expected '===' and instead saw '=='
855 }
856
857 if (f[0] == 'D') { // -- date
858 if (f.substr(0, 10) == '0000-00-00') {859 return ''
860 }
861
Expected '===' and instead saw '=='
854 return v.replace(CF[0], '').replace(' ', '').nuReplaceAll(CF[1], '').replace(CF[2], '.')
855 }
856
857 if (f[0] == 'D') { // -- date858 if (f.substr(0, 10) == '0000-00-00') {
859 return ''
860 }
Expected '===' and instead saw '=='
847 // var F = nuNumberFormat(f);
848 const CF = nuGetNumberFormat(f) // -- CF[0]=sign, CF[1]=separator, CF[2]=decimal, CF[3]=places
849
850 if (CF[2] == '') {851 return v.replace(CF[0], '').replace(' ', '').nuReplaceAll(CF[1], '')
852 }
853
Expected '===' and instead saw '=='
843 v = String(v)
844 f = String(f)
845
846 if (f[0] == 'N') { // -- number847 // var F = nuNumberFormat(f);
848 const CF = nuGetNumberFormat(f) // -- CF[0]=sign, CF[1]=separator, CF[2]=decimal, CF[3]=places
849
Expected '===' and instead saw '=='
838 if (v == undefined) { return '' }
839 if (f == undefined) { return v }
840 if (f == '') { return v }
841 if (v == '') { return v }842
843 v = String(v)
844 f = String(f)
Expected '===' and instead saw '=='
837 removeFormatting (v, f) {
838 if (v == undefined) { return '' }
839 if (f == undefined) { return v }
840 if (f == '') { return v }841 if (v == '') { return v }
842
843 v = String(v)
Expected '===' and instead saw '=='
836
837 removeFormatting (v, f) {
838 if (v == undefined) { return '' }
839 if (f == undefined) { return v }840 if (f == '') { return v }
841 if (v == '') { return v }
842
Expected '===' and instead saw '=='
835 }
836
837 removeFormatting (v, f) {
838 if (v == undefined) { return '' }839 if (f == undefined) { return v }
840 if (f == '') { return v }
841 if (v == '') { return v }
Expected '===' and instead saw '=='
788 var t = String(v.split(' ')[0]).split(':')
789 }
790
791 if (t[0] == 'undefined') {792 var t = [0, 0, 0]
793 }
794
Expected '===' and instead saw '=='
776
777 if (f[0] == 'D') { // -- date
778 if (String(v.split(' ')[0]) == '0000-00-00') { return '' }
779 if (v == '') { return '' }780
781 const FMT = this.setFormats()
782
Expected '===' and instead saw '=='
775 }
776
777 if (f[0] == 'D') { // -- date
778 if (String(v.split(' ')[0]) == '0000-00-00') { return '' }779 if (v == '') { return '' }
780
781 const FMT = this.setFormats()
Description
It is considered good practice to use the type-safe equality operators ===
and !==
instead of their regular counterparts ==
and !=
.
The strict equality operators (===
and !==
) use the strict equality comparison algorithm to compare two operands.
- If the operands are of different types, return
false
. - If both operands are objects, return
true
only if they refer to the same object. - If both operands are
null
or both operands areundefined
, returntrue
. - If either operand is
NaN
, returnfalse
. - Otherwise, compare the two operand's values:
- Numbers must have the same numeric values.
+0
and-0
are considered to be the same value. - Strings must have the same characters in the same order.
- Booleans must be both
true
or bothfalse
.
- Numbers must have the same numeric values.
The most notable difference between this operator and the equality (==
) operator is that if the operands are of different types, the ==
operator attempts to convert them to the same type before comparing.
Bad Practice
a == b
foo == true
bananas != 1
value == undefined
typeof foo == 'undefined'
'hello' != 'world'
0 == 0
true == true
foo == null
Recommended
a === b
foo === true
bananas !== 1
value === undefined
typeof foo === 'undefined'
'hello' !== 'world'
0 === 0
true === true
foo === null