What is this JS syntax? Assignment in expression? (x != null && (y = x))
问题 I'm working with this JS plugin, and I've encountered some syntax I've never seen before. I understand what it's doing, but I'm not sure why it works. Here's an example of one instance of it: settings.maxId != null && (params.max_id = settings.maxId); Is this just taking advantage of conditionals and the single = ? Is this common syntax for JS? 回答1: In JavaScript the = operator is an expression and evaluates the assigned value. Because it is an expression it can be used anywhere an expression