Expected '===' and instead saw '=='
15 const seller = await this.findById(req)
16 const sellerKey = await Validator.createAuthToken({...seller, isSeller: true}, process.env.SELLER_TOKEN_KEY) //mismo caso que con el salesManager
17
18 if(req.cookie != null && Validator.verify(req.cookie, sellerKey).id == seller.id){ 19 return res.json({message : "Su cuenta ha sido validada"})
20 }
21 else{
Expected '===' and instead saw '=='
15 const manager = await this.findById(req)
16 const managerKey = await Validator.createAuthToken({...manager, isSeller: true}, process.env.MANAGER_TOKEN_KEY) //como no tengo el archivo env voy a inventar el nombre del token
17
18 if(req.cookie != null && Validator.verify(req.cookie, managerKey).id == manager.id){ 19 return res.json({message : "Su cuenta ha sido validada"})
20 }
21 else{
Expected '===' and instead saw '=='
59 const client = await this.findById(req)
60 const clientKey = await Validator.createAuthToken({...client, isSeller: false}, process.env.CLIENT_TOKEN_KEY)
61
62 if(res.cookie != null && Validator.verify(res.cookie, clientKey).id == client.id){ //Duda, porque se usa el res y no el req?63
64 return res.json({message : "cuenta cliente validada"})
65
Expected '===' and instead saw '=='
30 //const {username, email, password, address} = req.body
31 const client = await this.findById(req)
32
33 if(client.email == req.body.email && client.password == req.body.password){34 const clientKey = await Validator.createAuthToken({...client, isSeller: false}, process.env.CLIENT_TOKEN_KEY)
35 res.set("Authorization", clientKey)
36 res.setHeader("Authorization", clientKey)
Expected '===' and instead saw '=='
30 //const {username, email, password, address} = req.body
31 const client = await this.findById(req)
32
33 if(client.email == req.body.email && client.password == req.body.password){34 const clientKey = await Validator.createAuthToken({...client, isSeller: false}, process.env.CLIENT_TOKEN_KEY)
35 res.set("Authorization", clientKey)
36 res.setHeader("Authorization", clientKey)
Expected '===' and instead saw '=='
14 async register(req, res){
15 //const {username, email, password, address} = req.body
16 const client = await this.create(req)
17 if(client.password == req.body.repeatPassword){18 const clientKey = await Validator.createAuthToken({...client, isSeller: false}, process.env.CLIENT_TOKEN_KEY)
19 res.set("Authorization", clientKey)
20 res.setHeader("Authorization", clientKey)
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