LESS.js – LESS variables does not work

Simple solution! I had included css file before I decided to use LESS so I just changed file css to less:

<link rel="stylesheet" type="text/css" href="css/style.less">
<script type="text/javascript" src="js/less.js"></script>

BUT, It did not work!

This worked:

<link rel="stylesheet/less" type="text/css" href="css/style.less">
<script type="text/javascript" src="js/less.js"></script>

U see difference? No? πŸ˜‰

rel="stylesheet/less"

Advertisements

JavaScript function with default values

In PHP you can define default values like this:

function add($a = 0, $b = 0) {
  return $a + $b;
}

So I did the same in JavaScript:

function add(a = 0, b = 0) {
  return a + b;
}

But it works only in Firefox. Other browsers do not support this format.
Cross browser default values should be defined like this:

function add(a, b) {
  a = a || 0;
  b = b || ;
  return a + b;
}