Javascript样式指导变量命名约定的相等性

时间:2016-02-22 05:30:33

标签: javascript

我在某个地方看到这个但它逃脱了我,我不记得了。变量命名约定的通用样式指南有哪些?例如:

const isPresent = [1,2,3].includes(someVariable)
const isPresent = [1,2,3].includes(1)
// or
const hasOne = [1,2,3].includes(1)

const isEqual = (1 === 1)
const isNotEqual = (1 === 2)
// or
const notEqual = (1 === 2)

const isNoAvailbility = [{...}, {...}].some(slot => slot.time === someTime)
// or
const hasNoAvailbility = [{...}, {...}].some(slot => slot.time === someTime)
// or
const noAvailbility = [{...}, {...}].some(slot => slot.time === someTime)
// or
const notAvailbile = [{...}, {...}].some(slot => slot.time === someTime)

const hasMessages = sentMessages.length || receivedMessages.length

这些是一些示例,您可以随意编辑和添加自己的示例。关键是,你什么时候使用is*has*,甚至是什么是常见的风格指南(我看过Airbnb而没有运气)?此外,在使用ishas时,变量的相似性是什么样的。

0 个答案:

没有答案