我在某个地方看到这个但它逃脱了我,我不记得了。变量命名约定的通用样式指南有哪些?例如:
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而没有运气)?此外,在使用is
或has
时,变量的相似性是什么样的。