<script> var myArray = []; @foreach (var d in Model.data) { // Using the @: operator //we can use javascript variables in razor C# @:myArray.push("@d"); } </script>