Question: I wrote this function to deeply compare two objects in JavaScript

```
Equal: function(obj1, obj2) {
  var keys1 = Object.keys(obj1).sort();
  var keys2 = Object.keys(obj2).sort();
  if (keys1.length !== keys2.length) {
    return false;
  }
  // first make sure have same keys.
  if (!keys1.every(function(k, i) {
    return (k === keys2[i]);
  })) {
    return false;
  }
  return keys1.every(function(kk) {
    var v1 = obj1[kk];
    var v2 = obj2[kk];
    if (Array.isArray(v1)) {
      return this.EqualArr(v1, v2);
    } else if (typeof v1 === "object" && v1 !== null) {
      return this.Equal(v1, v2);
    } else {
      return v1 === v2;
    }
  });
},

```

But I got this error:

> 
> Cannot convert undefined or null to object 
> 
> 
> 

The problem happens at this line:

```
var keys2 = Object.keys(obj2).sort(); 

```

Can anyone help me ?

Answer: 
Yep, it's the `attribute` method:

```
{% set t = [(1, 'hello'), (2, 'world')] %}
{% set t1 = t|map(attribute=1)|list %}
{{ t1 }}

```
Jinja engine is limited in terms of python expressions as per following [quote](http://jinja.pocoo.org/docs/dev/faq/#isn-t-it-a-terrible-idea-to-put-logic-into-templates) from Jinja documentation:

> 
> ...   
> 
>  Jinja2 neither allows you to put arbitrary Python code into
>  templates nor does it allow all Python expressions. ***The operators are
>  limited to the most common ones and more advanced expressions such as
>  list comprehensions and generator expressions are not supported***. This
>  keeps the template engine easier to maintain and templates more
>  readable.
> 
> 
> 

That's being said, you should do most of data processing in actual Python code or of you are using JS, just pass it as variables and process it with JS then render it and leave templates as clean as possible for easier maintenance.

Edit: Solution inspired from Jinja's docs:

Probably, this might work for you, which I found on [Jinja's docs](http://jinja.pocoo.org/docs/2.10/templates/#literals):

```
<ul>
{% for nb, word in t %}
    <li><a href="">{{ word }}</a></li>
{% endfor %}
</ul>

```