Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

homework first part #1

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,46 @@ function isNegativeZero (x) {
Напишите тест, который порывает все особенности этого алгоритма. Будет здорово если вы приложите ссылку на jsfiddle.net


См. также: [пост про домашние задания](http://clubs.ya.ru/4611686018427468886/replies.xml?item_no=450).
См. также: [пост про домашние задания](http://clubs.ya.ru/4611686018427468886/replies.xml?item_no=450).


<b>Задание:</b>
<br/>
0) Чему равно [] + {}
<br/>
1) Напишите функцию эмулирующую оператор new
<br/>
2) в Разработке...
<br/>

<b>Ответы:</b>
<ol>
<li> [] + {}

Mассив преобразуется в пустую строку, метод toString объекта выводит фразу - '[object Object]'
<p>
Ответ : [] + {} = '' + '[object Object]' = '[object Object]'
</p>
</li>

<li>
<code>
function A( arg ){
this.arg = arg;
};
<br/>
function myNew ( foo, args ) {
var obj = { '__proto__': foo.prototype };
foo.call ( obj, args );
return obj;
};
<br/>
var a = myNew( A , 10 );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

myNew(A, [1, 2, 3]); // Не будет выглядеть как new A(1, 2, 3); -- new A([1, 2, 3])
myNew("Im Hacker!"); // TypeError выброшен быть должен

<br/>
console.log( a.arg );
</code>
</li>
<li>
under constructions
</li>
</ol>