Why laravel collection can use directly as a javascript variable but not a php array or object?
In testing.blade.php
<?php
use Illuminate\Support\Collection;
$testingArray = [1,2,3];
$testingObject = new stdClass();
$testingObject->testing = "Testing";
$testingObject->hello = "Hello";
$testingObject->bye = "Bye";
$testingCollection = Collection::make($testingArray);
?>
<script>
var myArray = {!! $testingArray !!}; //Not work
var myObject = {!! $testingObject !!}; //Not work
var myArray = {!! json_encode($testingArray) !!}; //Work
var myObject = {!! json_encode($testingObject) !!}; //Work
var myCollection = {!! $testingCollection !!}; //Work
</script>
Any references?