CakePHP: Dynamically adding a javascript in the header

Since cake 1.2, there is already an implementation to dynamically add (or include) a javascript file in the header. This is done in case you need to include a new js file in the header on one of your modules. This will prevent putting the code in the default layout and loading unnecessary javascript files in the header.
<?php echo $javascript->link('nameofjstoadd',false); ?>
This is called in the default.ctp using $scripts_for_layout’ directive inside the header.